package com.example.idachuappone.person.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.idachuappone.R;
import com.example.idachuappone.person.entity.Help;
import java.util.List;

public class HelpAdapter extends BaseAdapter {
    private Context context;
    private List<Help> list;

    private class ViewHolder {
        private TextView tv_help_content;
        private TextView tv_help_title;

        private ViewHolder() {
        }
    }

    public HelpAdapter(Context context) {
        this.context = context;
    }

    public void setList(List<Help> list) {
        this.list = list;
    }

    public int getCount() {
        return this.list == null ? 0 : this.list.size();
    }

    public Object getItem(int position) {
        return this.list == null ? null : (Help) this.list.get(position);
    }

    public long getItemId(int position) {
        return (long) position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LinearLayout.inflate(this.context, R.layout.simple_help_item, null);
            holder.tv_help_content = (TextView) convertView.findViewById(R.id.tv_help_content);
            holder.tv_help_title = (TextView) convertView.findViewById(R.id.tv_help_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Help help = (Help) this.list.get(position);
        holder.tv_help_content.setText(help.getContent());
        holder.tv_help_title.setText(help.getTitle());
        return convertView;
    }
}
